package com.sxt.springsecuritytest2.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/*
 *
 * @Description todo
 * @author qqg
 * @date $date$
 * @param $params$ 
 * @return $return$
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUser implements Serializable, UserDetails {
    private Integer id;

    /**
    * 用户名称
    */
    private String username;

    /**
    * 密码
    */
    private String password;

    /**
    * 1开启0关闭
    */
    private Integer status;

    /*
     *  角色列表
     */
    private List<SysRole> roles  = new ArrayList<>();
//    private List<String> roles  = new ArrayList<>();


    private static final long serialVersionUID = 1L;

    @JsonIgnore
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roles;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
    @JsonIgnore
    @Override
    public boolean isEnabled() {
        return true;
    }
}